package cn.androidlongs.study.sub.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.androidlongs.study.sub.vo.CommonUserSubjectModel;
import cn.androidlongs.study.user.vo.UserModel;

public class SubDao extends HibernateDaoSupport{

    public List<CommonUserSubjectModel> queryAllCommonSubList() {
	String hql = "from CommonUserSubjectModel ";
	List<CommonUserSubjectModel> list = this.getHibernateTemplate().find(hql);
	return list;
    }

    public CommonUserSubjectModel queryCommonSubFromUUID(String subUUid) {
	String hql = "from CommonUserSubjectModel where uSubUid=?";
	List<CommonUserSubjectModel> list = this.getHibernateTemplate().find(hql,subUUid);
	if (list!=null&&list.size()>0) {
	    return list.get(0);
	}
	return null;
    }

    public void updateSubFunction(CommonUserSubjectModel cSubjectModel) {
	this.getHibernateTemplate().saveOrUpdate(cSubjectModel);
    }

    public void addNewComSub(CommonUserSubjectModel subjectModel) {
	this.getHibernateTemplate().save(subjectModel);
	
    }

    public void deleteSubFunction(CommonUserSubjectModel subjectModel) {
	this.getHibernateTemplate().delete(subjectModel);
    }

}
